#!/bin/bash


if [ $(emacsclient -e '(message "1")') != "\"1\"" ];
then
    echo "Emacs dameon must be running!"
    exit 0
fi

PACKAGES=$(emacsclient -e "(symbol-value 'package-activated-list)" | sed "s/(/(setq package-list '(/g" | sed "s|)|))|g")
PACKAGES="; starting-packages\n${PACKAGES}\n; ending-packages"
sed "/starting-packages/,/ending-packages/c${PACKAGES}" "${DOTFILES_DIR}/.emacs.d/myinit.org" -i
